/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.service.services.views.orgchart;

import java.awt.Graphics;

import javax.swing.JPanel;


/**
 * Panel representing the enclosing panel of an orgchart in "semalike" mode.
 */
public class XJPanel3 extends JPanel
{
    /** Size of cell at head of orgchart. */
    private int h = 0;

    /** Flag set to true if last orgchart line is not complete. */
    private boolean reste = false;

    /** Space. */
    private final int dh = 10;

    /**
     * Sets size of cell at head of orgchart.
     *
     * @param value  Cell height.
     */
    public final void setH(final int value)
    {
        h = value;
    }

    /**
     * Sets a flag to true if last orgchart line is not complete.
     *
     * @param r  Number of cells in last orgchart line.
     */
    public final void setReste(final int r)
    {
        if (r > 0)
        {
            reste = true;
        }
    }

    /**
     * Draws the component.
     *
     * @param g  Graphics on which to draw.
     */
    @Override
	public final void paint(final Graphics g)
    {
        super.paint(g);

        int w = getWidth();
        int end = getHeight() - h - dh;

        if (!reste)
        {
            end = end - dh;
        }

        g.drawLine(w / 2, h, w / 2, end);
        g.drawLine((w / 2) + 1, h, (w / 2) + 1, end);
    }
}
